<template>
    <div class="app-container">
        <el-row :gutter="20">
            <!-- <el-col :span="20" :xs="24">
                <el-form-item label="操作时间" style="width: 308px;">
                    <el-date-picker v-model="dateRange" value-format="YYYY-MM-DD hh:mm:ss"
                        type="datetime"></el-date-picker>
                </el-form-item>
            </el-col> -->

            <el-col :span="14" :xs="24">
                <el-form-item label="" prop="misfirePolicy">
                    <el-radio-group v-model="runmodelNumber" style="width: 100%;">
                        <el-radio :disabled="lock" v-for="(item, index) in runmodelList" class="radio"
                            :label="item.runmodelNumber" border>
                            {{ item.runmodelName }}</el-radio>

                    </el-radio-group>
                </el-form-item>
            </el-col>
            <el-col :span="12" :xs="24">

                <el-button style="float: right;  margin-left: 10px" type="primary" plain icon="Check"
                    @click="updateNumber">确认</el-button>
                <el-button style="float: right;;" type="primary" plain icon="Lock" @click="updateLock">解锁</el-button>
            </el-col>
        </el-row>
    </div>
</template>

<script setup name="Runmodel">
import { listRunmodel, editNumber } from "@/api/factoryInfo/runmodel/runmodel";
const { proxy } = getCurrentInstance();
import { ref } from 'vue';
const runmodelList = ref([]);
const lock = ref(true);
const runmodelNumber = ref('');


function updateLock() {
    lock.value = false;
}

getList();
function getList() {
    listRunmodel({}).then(response => {
        runmodelList.value = response.data;
        runmodelList.value.forEach(e => {
            if (e.isRunning == 1) {
                runmodelNumber.value = e.runmodelNumber;
            }
        })
    });
}

async function updateNumber() {
    proxy.$modal.confirm('是否要提交设置').then(function () {
        return editNumber({ runmodelNumber: runmodelNumber.value });
    }).then(() => {
        getList();
        proxy.$modal.msgSuccess("设置成功");
    }).catch(() => { });
}

</script>

<style lang='scss' scoped>
.radio {
    width: 100%;
    margin: 20px;
}
</style>